<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>strncpy</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">Standard C String and Character</a> &gt; <a href=
    "strncpy.html">strncpy</a>
  </div>

  <div class="name-format">
    strncpy
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  char *strncpy( char *to, const char *from, size_t count );
</pre>

  <p>The strncpy() function copies at most <em>count</em> characters of
  <em>from</em> to the string <em>to</em>. If from has less than
  <em>count</em> characters, the remainder is padded with &#39;\0&#39;
  characters. The return value is the resulting string.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memcpy.html">memcpy</a><br>
    <a href="strchr.html">strchr</a><br>
    <a href="strcpy.html">strcpy</a><br>
    <a href="strncat.html">strncat</a><br>
    <a href="strncmp.html">strncmp</a>
  </div>

  <p>Another set of related (but non-standard) functions are <a
  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and
  strlcat</a>.</p>

  </div>
  </td>
  


  </tr>
  </table>
</body></html>
